package cn.funeralobjects.ams.web.controller;

import cn.funeralobjects.ams.entity.ERegion;
import cn.funeralobjects.ams.model.Region;
import cn.funeralobjects.ams.service.BaseAmsService;
import cn.funeralobjects.ams.service.RegionService;
import cn.funeralobjects.ams.web.api.RegionApi;
import cn.funeralobjects.ams.web.mapper.RegionMapper;
import cn.funeralobjects.ams.web.model.MRegion;
import cn.funeralobjects.ams.web.model.VRegion;
import cn.funeralobjects.common.web.controller.converter.ModelMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

/**
 * @author FuneralObjects
 * Create date: 2020/5/26 9:09 AM
 */
@RestController
@RequestMapping("/region")
public class RegionController implements RegionApi, BaseAmsController<VRegion, MRegion, Region, ERegion, Integer> {

    @Resource
    private RegionService regionService;
    @Resource
    private RegionMapper regionMapper;

    @Override
    public BaseAmsService<Region, ERegion, Integer> baseAmsService() {
        return regionService;
    }

    @Override
    public ModelMapper<MRegion, Region, ERegion, VRegion> modelMapper() {
        return regionMapper;
    }


    @GetMapping("/region-id-{regionId}")
    @Override
    public Mono<VRegion> findByRegionId(@PathVariable String regionId) {
        return this.findByCode(regionId);
    }
}
